import java.util.Scanner;


import static java.lang.StrictMath.sqrt;

/**
 * @Author :Shilaiyuan
 * @Date:2019-10-25
 * @Description:
 * 声明三棱锥类triangular，实现Area和Volume接口，计算表面area和体积volume*
 * 四棱锥的面积：海伦-秦九韶公式
 * 四棱锥的体积：欧拉四面体公式
 */
interface Area{
   // double TriangularArea(double OA,double OB,double OC,double AB,double AC,double BC);用来计算各面三角形的面积
   abstract double TriangularArea();
}

interface Volume{
    //double Volume(double OA, double OB, double OC, double AB, double AC,double BC);//用来计算体积
   abstract double TriangularArea();
}

public class triangular implements Area,Volume{
    private static double[] leng;
    private double[] x;

    public double TriangularArea() {//海伦公式计算四个面的面积
        double p1,p2,p3,p4;//p1为面OAB,p2为面OAC,p3为面OBC,p4为面ABC
        double s,s1,s2,s3,s4;//s为表面积,s1为OAB面积，s2为OAC面积，s3为OBC面积，s4为ABC面积
        x=leng;
        //OAB
        p1=(x[0]+x[1]+x[3])/2;
        s1=sqrt(p1*(p1-x[0])*(p1-x[1])*(p1-x[3]));
        //OAC
        p2=(x[0]+x[2]+x[4])/2;
        s2=sqrt(p2*(p2-x[0])*(p2-x[2])*(p2-x[4]));
        //OBC
        p3=(x[1]+x[2]+x[5])/2;
        s3=sqrt(p3*(p3-x[1])*(p3-x[2])*(p3-x[5]));
        //ABC
        p4=(x[3]+x[4]+x[5])/2;
        s4=sqrt(p4*(p4-x[3])*(p4-x[4])*(p1-x[5]));
        s=s1+s2+s3+s4;
        System.out.println("四棱锥的侧面积为:\n OAB="+s1+";\n OAC="+s2+";\n OBC="+s3+";\n ABC="+s4);
        System.out.println("四棱锥的表面积为"+s);
        return 0.0;
    }


    public double Volume() {//欧拉四面体公式计算体积
        x=leng;
        double v,z;
        double r=x[0]*x[0];
        double p=x[1]*x[1];
        double q=x[2]*x[2];
        double i=x[3]*x[3];
        double j=x[4]*x[4];
        double k=x[5]*x[5];
        double s1=(r+p-i)/2;
        double s2=(r+q-j)/2;
        double s3=(p+q-k)/2;
        z=r*(p*q-s3*s3)-s1*(s1*q-s2*s3)+s2*(s1*s3-p*s2);
        v=sqrt(z);
        System.out.println("四棱锥的体积为："+v);
        return 0;
    }

    public static void main(String[] args){
        System.out.println("请依次输入三棱锥的棱长OA,OB,OC,AB,AC,BC");
        Scanner sc = new Scanner(System.in);
        String str = sc.nextLine().toString();
        String arr[] = str.split(",");
        double n[] = new double[6];//数组n存储每一个棱长
        for(int i=0;i<n.length;i++){
            n[i]=Integer.parseInt(arr[i]);
        }
        triangular t1 = new triangular();
        leng=n;
        t1.TriangularArea();
        t1.Volume();
    }

}
